Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

test: Fix some tests #52

Merged
merged 1 commit into from
Feb 10, 2020
Merged

test: Fix some tests #52

merged 1 commit into from
Feb 10, 2020

Conversation

belemaire
Copy link
Contributor

After a fresh clone/install of the project npm test is failing on some tests, when testing equality of array fixture v.s array produced by test.

The array content is similar to the fixture one, but not ordered the same way, failing jest expect.toEqual call.

After looking into it, it's just due to an incorrect implementation of the compareFunction provided to sort function. This function should return either 1 (if a > b), -1 (if a < b) or 0 (if a === b), but current implementation was returning a bool being coerced to 0 (if false) or 1 (if true), leading to the problem.

Please note that this failure wasn't noticed before because it is dependent on the version of node being used. I was running current LTS (12.15.0) when running into this test failure, but the test failure does not appear when running Node 8 (I didn't try other versions, so not sure from which version it appears). Probably due to a different internal implementation of the sort function in recent node versions, dealing a bit differently with ordering of identical values.

Copy link
Contributor

@bengourley bengourley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test did occasionally flake for me and I wondered why. Thanks for taking the time to investigate and fix it! 🙏

@bengourley bengourley merged commit 4618ca6 into bugsnag:master Feb 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants